package com.hualan.zhsq.controller.property;

import com.hualan.zhsq.entity.property.Announcement;
import com.hualan.zhsq.service.property.AnnouncementService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AnnouncementController
 * @Description 公告controller
 * @Author ZheRan
 * @Date 2025年08月04日 下午8:21
 * @Version 1.0
 */
@RestController
public class AnnouncementController {
    @Autowired
    private AnnouncementService announcementService;

    //新增一条数据
    @PostMapping("/announcement/add")
    public Result add (@RequestBody Announcement announcement){
        return Result.success(announcementService.add(announcement));
    }

    //根据id修改一条数据
    @PutMapping("/announcement/edit")
    public Result edit (@RequestBody Announcement announcement){
        return Result.success(announcementService.edit(announcement));
    }

    //根据id删除一条数据
    @DeleteMapping("/announcement/remove/{id}")
    public Result remove(@PathVariable Integer id){
        return Result.success(announcementService.remove(id));
    }

    //批量逻辑删除数据
    @DeleteMapping("/announcement/removeBatch")
    public Result removeBatch(@RequestBody Integer[] ids){
        return Result.success(announcementService.removeBatch(ids));
    }

    //根据id查询一条数据
    @GetMapping("/announcement/findById/{id}")
    public Result findById(@PathVariable Integer id){
        return Result.success(announcementService.findById(id));
    }

    //查询所有数据
    @GetMapping("/announcement/findPage")
    public Result findPage(){
        return Result.success(announcementService.findPage(1,10,new Announcement()));
    }
}
